package cn.com.lms.business.report.service;

import cn.com.lms.business.learning.persistence.entity.FbLearningStudent;
import cn.com.lms.business.learning.persistence.repository.LearningStudentRepository;
import cn.com.lms.business.report.web.vo.CourseLearnReportVo;
import cn.com.lms.business.report.web.vo.CourseLearnUserReportVO;


import com.bnzj.core.persistence.BaseService;
import com.bnzj.core.persistence.query.QueryHelpBean;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;

@Service
public class CourseLearnUserReportService extends BaseService<LearningStudentRepository, FbLearningStudent,Long> {


    public QueryHelpBean getQueryHelpBean() {
        String selectSQL = "select sd.id, s.user_name,su.full_dept_name,s.last_study_time,(select count(1) from bnz_learning_student st left  join bnz_learning_stage_detail sd1 on sd1.id=st.stage_detail_id  where sd1.obj_id=sd.obj_id and  st.finish_state=1 and  st.user_id=s.user_id) finish_count,(select count(1) from bnz_learning_student st left  join bnz_learning_stage_detail sd1 on sd1.id=st.stage_detail_id  where sd1.obj_id=sd.obj_id and   st.user_id=s.user_id   ) count";
        String whereSQL = " from bnz_learning_student s LEFT JOIN bnz_learning_stage_detail sd on s.stage_detail_id=sd.id  left join bnz_sys_user su on su.id=s.user_id " +
                " where sd.study_type=0  ";
        QueryHelpBean queryBean = new QueryHelpBean(selectSQL + whereSQL, "select count(1)" + whereSQL, CourseLearnUserReportVO.class);
        return queryBean;
    }





}
